<template>
	<view>
		<view class="card">
			<view class="card-title flex align-center">
				<text>考试技巧</text>
			</view>
			<view v-for="(item2, index) in paperList" :key="item2.id_" class="cell flex align-center"
				@click="handSkill(index)">
				<image :src="item2.icon" mode=""></image>
				<view class="info">
					<view class="name">{{ item2.title_ }}</view>
					<view class="desc">{{ item2.sub_title }}</view>
				</view>
				<view class="icon">
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		skillPaperList
	} from '@/api/skill.js'
	import {
		mapGetters
	} from 'vuex'
	import {
		checkUserUnlock
	} from '@/api/home.js'
	export default {
		data() {
			return {
				paperList: [],
				city: ''
			};
		},
		computed: {
			...mapGetters('app', {
				token: 'token',
			})
		},
		onLoad(e) {
			this.city = e.city
			this.getsiklllist()
		},
		methods: {
			async getsiklllist() {
				let {
					data,
					message,
					code
				} = await skillPaperList({
					city: this.city
				})
				this.paperList = data
			},
			handSkill(e) {
				if (!this.token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				this.getskilcheck(this.paperList[e])
			},
			//技巧是否解锁
			async getskilcheck(info) {
				const {
					data
				} = await checkUserUnlock({
					city: info.city_
				})
				let Unlock = data
				if (info.city_ == '0') {
					if (Unlock.national.is_unlock_skill == 0) {
						// uni.showToast({
						// 	title: '全国技巧题暂未解锁',
						// 	icon: 'none'
						// })
						// setTimeout(() => {
						// 	uni.navigateTo({
						// 		url: '/pages/paper/Set_meal?city=' + info.city_
						// 	})
						// }, 700)
						uni.navigateTo({
							url: '/pages/paper/Set_meal?city=' + info.city_
						})
						return
					}
				} else {
					if (Unlock.city.is_unlock_skill == 0) {
						// uni.showToast({
						// 	title: this.city + '技巧题暂未解锁',
						// 	icon: 'none'
						// })
						// setTimeout(() => {
						// 	uni.navigateTo({
						// 		url: '/pages/paper/Set_meal?city=' + info.city_
						// 	})
						// }, 700)
						uni.navigateTo({
							url: '/pages/paper/Set_meal?city=' + info.city_
						})
						return
					}
				}
				// if (this.userinfo.is_unlock === 0) {
				// 	this.$refs.lock.showEdit()
				// 	return
				// }
				uni.navigateTo({
					url: `/pages/skill/index?city=${info.city_}&id=${info.id_}`
				})
				// if (this.userinfo.is_unlock === 0) {
				// 	this.$refs.lock.showEdit()
				// 	return
				// }
				// this.paperList = data
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		width: 702rpx;
		margin: 24rpx auto 0 auto;
		background-color: #ffffff;
		border-radius: 16rpx;
		box-sizing: border-box;
		padding: 24rpx;

		&-title {
			font-size: 38rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;

			text {
				&:nth-child(2) {
					margin-left: 12rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}
		}

		.grid {
			margin-top: 36rpx;

			&-item {
				flex: 1;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				image {
					width: 80rpx;
					height: 80rpx;
				}

				text {
					margin-top: 16rpx;
					font-size: 26rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: bold;
					color: #333333;
				}
			}
		}

		.cell {
			margin-top: 24rpx;
			padding: 32rpx 20rpx;
			background-color: #F6F7FF;
			border-radius: 16rpx;

			image {
				width: 74rpx;
				height: 74rpx;
			}

			.info {
				margin-left: 24rpx;
				flex: 1;

				.name {
					font-size: 38rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
				}

				.desc {
					margin-top: 10rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
				}
			}
		}
	}
</style>